<?php

namespace app\model;


use fast\Http;
use think\facade\Log;

class Feature
{

    public function compare_all_feature($feature, string $scheme,$score,$start_time,$end_time,$log_id) {
        if(!$start_time){
            $start_time='2000-01-01 00:00:00';
        }
        if(!$end_time){
            $end_time='2999-01-01 00:00:00';
        }
        /*$command = "python3 ".config('capture.py_url')." $feature $table_name $score $start_time $end_time $log_id";
        Log::info($log_id.'开始调用python:'.$command);
        $output = shell_exec($command);*/
        $info=compact("feature","scheme","score","start_time","end_time","log_id");
        $info['score']=$info['score']/100;
        $output=Http::post('http://127.0.0.1:5000/process',json_encode($info),[CURLOPT_HTTPHEADER=>['Content-Type:application/json'],CURLOPT_TIMEOUT=>10000]);
        Log::info($log_id.'调用python结果：'.$output);
        return json_decode($output,true);
    }

    public function compare_feature($feature, string $scheme, float $score, $log_id) {
        $info=compact("feature","scheme","score","log_id");
        $info['score']=$info['score']/100;
        $output=Http::post('http://127.0.0.1:6004/proc',json_encode($info),[CURLOPT_HTTPHEADER=>['Content-Type:application/json'],CURLOPT_TIMEOUT=>10000]);
        Log::info($log_id.'调用python结果：'.$output);
        return json_decode($output,true);
    }

    public function compare_feature1($feature, string $scheme, float $score, $log_id) {
        $info=compact("feature","scheme","score","log_id");
        $info['score']=$info['score']/100;
        $output=Http::post('http://127.0.0.1:6001/proc1',json_encode($info),[CURLOPT_HTTPHEADER=>['Content-Type:application/json'],CURLOPT_TIMEOUT=>10000]);
        Log::info($log_id.'调用python结果：'.$output);
        return json_decode($output,true);
    }

    public function compare_feature2($feature, string $scheme, float $score, $log_id) {
        $info=compact("feature","scheme","score","log_id");
        $info['score']=$info['score']/100;
        $output=Http::post('http://127.0.0.1:6004/proc',json_encode($info),[CURLOPT_HTTPHEADER=>['Content-Type:application/json'],CURLOPT_TIMEOUT=>10000]);
        Log::info($log_id.'调用python结果：'.$output);
        return json_decode($output,true);
    }

    public function compare_feature3($feature, string $scheme, float $score, $log_id) {
        $info=compact("feature","scheme","score","log_id");
        $info['score']=$info['score']/100;
        $output=Http::post('http://127.0.0.1:6004/proc',json_encode($info),[CURLOPT_HTTPHEADER=>['Content-Type:application/json'],CURLOPT_TIMEOUT=>10000]);
        Log::info($log_id.'调用python结果：'.$output);
        return json_decode($output,true);
    }
}